// ///////////////////////////// MIT License //////////////////////////////////// //
//                                                                                //
// Copyright (c) 2010 David Zsolt Manrique                                        //
//                    david.zsolt.manrique@gmail.com                              //
//                                                                                //
// Permission is hereby granted, free of charge, to any person obtaining a copy   //
// of this software and associated documentation files (the "Software"), to deal  //
// in the Software without restriction, including without limitation the rights   //
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell      //
// copies of the Software, and to permit persons to whom the Software is          //
// furnished to do so, subject to the following conditions:                       //
//                                                                                //
// The above copyright notice and this permission notice shall be included in     //
// all copies or substantial portions of the Software.                            //
//                                                                                //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR     //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,       //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE    //
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER         //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  //
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN      //
// THE SOFTWARE.                                                                  //
//                                                                                //
// ////////////////////////////////////////////////////////////////////////////// //

#include "hamiltonian.h"

using namespace std;


int main(int argc, char* argv[])
{
try
{
        cmd::arguments arg(argc,argv);
        cmd::switcharg<false> help(arg,"-h","--help", "print help message");

//        cmd::switcharg<false> rw(arg,"-rw","--rewrite", "rewrite input");

//        cmd::vararg<double> tol(arg,"-tol","--tol"," X tolerance def.: 1e-5",1.0e-5);
        cmd::vararg<double> ef(arg,"-ef","--ef"," Fermi energy shift to zero",0.0);
        cmd::vararg<double> iv(arg,"-iv","--iv"," symetric bias iv around <arg> energy [nA/V] if energy scale in eV",0.0);
        cmd::switcharg<false> samech(arg,"-ch","--same-ch", "filter same channel");

        cmd::varargxx<double,double> trange(arg,"-tr","--trange"," transmission filter range",0.0,1.0);
        cmd::varargxx<double,double> erange(arg,"-er","--erange"," energy filter range",-5.0,5.0);
        
        cmd::vararg<int> average(arg,"-av","--average"," average window",3);


        cmd::vararg<double> smooth(arg,"-smo","--smooth"," filtering jumps with <arg> derivatives",0.01);
        cmd::vararg<double> logsmooth(arg,"-logsmo","--logsmooth"," filtering jumps with <arg> derivatives of log",0.01);

        cmd::switcharg<false> xmgrace(arg,"-xmg","--xmgrace"," generating xmgrace output");

        cmd::posarg<std::string> trfile(arg,"tr input file", "");

        if(*help)
        {
                arg.print_help(std::cout,"posttr");
                std::cout << "version 0.95b" << std::endl;
                std::cout << "Copyright (c) 2010 David Zsolt Manrique (david.zsolt.manrique@gmail.com)"  << std::endl;
                return EXIT_SUCCESS;
        }
        
        if(!~trfile) throw std::runtime_error("Give transmission file!");

        std::vector<std::string> lines;
        io::load(*trfile,"#",lines);
        
//        for(int i =0;i<lines.size();i++) std::cout << lines[i]<<std::endl;        
        
        std::vector<double> en,tab,tba,raa,rbb,err;
        std::vector<int> aoc,boc;
        std::vector<int> mark;
        for(int i=0;i<lines.size();i++)
        if(!lines[i].empty())
        {
            std::istringstream iss(lines[i]);
            double tmp;
            int itmp;
            iss >> tmp; en.push_back(tmp);
            iss >> tmp; tab.push_back(tmp);
            iss >> tmp; tba.push_back(tmp);
            iss >> tmp; raa.push_back(tmp);
            iss >> tmp; rbb.push_back(tmp);
            iss >> itmp; aoc.push_back(itmp);
            iss >> itmp; boc.push_back(itmp);
            iss >> tmp; err.push_back(tmp);
            mark.push_back(1);
        }        
        
        int N=en.size();
        
        if(~ef) 
        {   
            for(int i=0;i<N;i++)
            {
                 std::cout << en[i]-*ef << "  " << tab[i] << std::endl;
            }
        }  
        else if(~samech) 
        { 
            for(int i=0;i<N;i++)
            {
                 if(aoc[i] == boc[i] ) std::cout << en[i] << "  " << tab[i] << std::endl;
            }
            
        }
        else if(~iv)
        {
            double e0=*iv;

            for(double u=-2.0;u<0.0;u+=0.01)
            {
                int n=0;
                double iii = 0.0;
                for(int j=0;j<N;j++) { if( (en[j]-e0 <= -u/2.0) && (u/2.0 <= en[j]-e0) ) { iii+=tab[j];  n++; } }
                iii *= u;
                iii /= double(n);            
                std::cout << u << "  " << iii << std::endl;
            }
            
            for(double u=0.0;u<2.0;u+=0.01)
            {
                int n=0;
                double iii = 0.0;
                for(int j=0;j<N;j++) { if( (en[j]-e0 <= u/2.0) && (-u/2.0 <= en[j]-e0) ) { iii+=tab[j];  n++; } }
                iii *= u;
                iii /= double(n);            
                std::cout << u << "  " << iii << std::endl;
            }
        }
/*        else if(~average)
        {
            int i = 0;
            int d=*average;
            while(i<N)
            {
                int i0,i1,i2;
                bool on = false;
                i0=i;
                while(i<N) { if((trange.var1 <= tab[i]) && (tab[i] <= trange.var2 ) && (erange.var1 <= en[i]) && (en[i] <= erange.var2 )) { if(!on) { on=true; i1=i; } }
                else { if(on) { on=false; i2=i; break; } } i++; }
                
                for(int j = i0; j < i1; j++) std::cout << en[j] << "  " << tab[j] << std::endl;
                if(i2-i1 < d) 
                    for(int j = i1; j < i2; j++) std::cout << en[j] << "  " << tab[j] << std::endl;
                else
                    for(int j = i1; j < i2-d; j++) 
                    {
                        double sum=0.0,sume=0.0;
                        for(int k=0;k<d;k++) { sume+=en[j+k]; sum+=tab[j+k]; }
                        sume/=double(d);
                        sum/=double(d);
                        std::cout << sume << "  " << sum << std::endl;
                    }
                
            }
        }            */
        else if(~average)
        {
            int i = 0;
            int d=*average;
            while(i<N)
            {
                int i0,i1,i2;
                bool on = (trange.var1 <= tab[i]) && (tab[i] <= trange.var2 ) && (erange.var1 <= en[i]) && (en[i] <= erange.var2 );
                i0=i;
                while(i<N) { if(((trange.var1 <= tab[i]) && (tab[i] <= trange.var2 ) && (erange.var1 <= en[i]) && (en[i] <= erange.var2 )) != on) break; i++; }
                i1=i;
                
                if( (!on) || (on && (i1-i0<d) ) )
                    for(int j = i0; j < i1; j++) std::cout << en[j] << "  " << tab[j] << std::endl;
                else
                    for(int j = i0; j < i1-d; j++) 
                    {
                        double sum=0.0,sume=0.0;
                        for(int k=0;k<d;k++) { sume+=en[j+k]; sum+=tab[j+k]; }
                        sume/=double(d);
                        sum/=double(d);
                        std::cout << sume << "  " << sum << std::endl;
                    }
                
            }
        }            
        else if(~smooth)
        {
            int i = 0;
            double rr=*smooth;
            while(i<N)
            {
                int i0,i1,i2;
                bool on = (trange.var1 <= tab[i]) && (tab[i] <= trange.var2 ) && (erange.var1 <= en[i]) && (en[i] <= erange.var2 );
                i0=i;
                while(i<N) { if(((trange.var1 <= tab[i]) && (tab[i] <= trange.var2 ) && (erange.var1 <= en[i]) && (en[i] <= erange.var2 )) != on) break; i++; }
                i1=i;
                
                if( (!on) || (on && (i1-i0<2) ) )
                    for(int j = i0; j < i1; j++) std::cout << en[j] << "  " << tab[j] << std::endl;
                else
                    for(int j = i0; j < i1; j++) 
                    {
                        std::cout << en[j] << "  " << tab[j] << std::endl;
                        if(std::abs(tab[j+1]-tab[j]) > rr) j++;
                    }
                
            }

        }            
        else if(~logsmooth)
        {
            int i = 0;
            double rr=*logsmooth;
            while(i<N)
            {
                int i0,i1,i2;
                bool on = (trange.var1 <= tab[i]) && (tab[i] <= trange.var2 ) && (erange.var1 <= en[i]) && (en[i] <= erange.var2 );
                i0=i;
                while(i<N) { if(((trange.var1 <= tab[i]) && (tab[i] <= trange.var2 ) && (erange.var1 <= en[i]) && (en[i] <= erange.var2 )) != on) break; i++; }
                i1=i;
                
                if( (!on) || (on && (i1-i0<2) ) )
                    for(int j = i0; j < i1; j++) std::cout << en[j] << "  " << tab[j] << std::endl;
                else
                    for(int j = i0; j < i1; j++) 
                    {
                        std::cout << en[j] << "  " << tab[j] << std::endl;
                        if(std::abs(std::log(tab[j+1])-log(tab[j])) > rr)  j++; 
                    }
                
            }

        }            
        else if(~xmgrace)
        {
		std::cout << "# Grace project file" << std::endl;
		std::cout << "#" << std::endl;
		std::cout << "@version 50122" << std::endl;
		std::cout << "@page size 792, 612" << std::endl;
		std::cout << "@page scroll 5%" << std::endl;
		std::cout << "@page inout 5%" << std::endl;
		std::cout << "@link page off" << std::endl;
		std::cout << "@map font 0 to \"Times-Roman\", \"Times-Roman\"" << std::endl;
		std::cout << "@map font 1 to \"Times-Italic\", \"Times-Italic\"" << std::endl;
		std::cout << "@map font 2 to \"Times-Bold\", \"Times-Bold\"" << std::endl;
		std::cout << "@map font 3 to \"Times-BoldItalic\", \"Times-BoldItalic\"" << std::endl;
		std::cout << "@map font 4 to \"Helvetica\", \"Helvetica\"" << std::endl;
		std::cout << "@map font 5 to \"Helvetica-Oblique\", \"Helvetica-Oblique\"" << std::endl;
		std::cout << "@map font 6 to \"Helvetica-Bold\", \"Helvetica-Bold\"" << std::endl;
		std::cout << "@map font 7 to \"Helvetica-BoldOblique\", \"Helvetica-BoldOblique\"" << std::endl;
		std::cout << "@map font 8 to \"Courier\", \"Courier\"" << std::endl;
		std::cout << "@map font 9 to \"Courier-Oblique\", \"Courier-Oblique\"" << std::endl;
		std::cout << "@map font 10 to \"Courier-Bold\", \"Courier-Bold\"" << std::endl;
		std::cout << "@map font 11 to \"Courier-BoldOblique\", \"Courier-BoldOblique\"" << std::endl;
		std::cout << "@map font 12 to \"Symbol\", \"Symbol\"" << std::endl;
		std::cout << "@map font 13 to \"ZapfDingbats\", \"ZapfDingbats\"" << std::endl;
		std::cout << "@map color 0 to (255, 255, 255), \"white\"" << std::endl;
		std::cout << "@map color 1 to (0, 0, 0), \"black\"" << std::endl;
		std::cout << "@map color 2 to (255, 0, 0), \"red\"" << std::endl;
		std::cout << "@map color 3 to (0, 255, 0), \"green\"" << std::endl;
		std::cout << "@map color 4 to (0, 0, 255), \"blue\"" << std::endl;
		std::cout << "@map color 5 to (255, 255, 0), \"yellow\"" << std::endl;
		std::cout << "@map color 6 to (188, 143, 143), \"brown\"" << std::endl;
		std::cout << "@map color 7 to (220, 220, 220), \"grey\"" << std::endl;
		std::cout << "@map color 8 to (148, 0, 211), \"violet\"" << std::endl;
		std::cout << "@map color 9 to (0, 255, 255), \"cyan\"" << std::endl;
		std::cout << "@map color 10 to (255, 0, 255), \"magenta\"" << std::endl;
		std::cout << "@map color 11 to (255, 165, 0), \"orange\"" << std::endl;
		std::cout << "@map color 12 to (114, 33, 188), \"indigo\"" << std::endl;
		std::cout << "@map color 13 to (103, 7, 72), \"maroon\"" << std::endl;
		std::cout << "@map color 14 to (64, 224, 208), \"turquoise\"" << std::endl;
		std::cout << "@map color 15 to (0, 139, 0), \"green4\"" << std::endl;
		std::cout << "@reference date 0" << std::endl;
		std::cout << "@date wrap off" << std::endl;
		std::cout << "@date wrap year 1950" << std::endl;
		std::cout << "@default linewidth 1.0" << std::endl;
		std::cout << "@default linestyle 1" << std::endl;
		std::cout << "@default color 1" << std::endl;
		std::cout << "@default pattern 1" << std::endl;
		std::cout << "@default font 0" << std::endl;
		std::cout << "@default char size 1.000000" << std::endl;
		std::cout << "@default symbol size 1.000000" << std::endl;
		std::cout << "@default sformat \"%.8g\"" << std::endl;
		std::cout << "@background color 0" << std::endl;
		std::cout << "@page background fill on" << std::endl;
		std::cout << "@timestamp off" << std::endl;
		std::cout << "@timestamp 0.03, 0.03" << std::endl;
		std::cout << "@timestamp color 1" << std::endl;
		std::cout << "@timestamp rot 0" << std::endl;
		std::cout << "@timestamp font 0" << std::endl;
		std::cout << "@timestamp char size 1.000000" << std::endl;
		std::cout << "@timestamp def \"Sat Sep 24 14:31:52 2011\"" << std::endl;
		std::cout << "@r0 off" << std::endl;
		std::cout << "@link r0 to g0" << std::endl;
		std::cout << "@r0 type above" << std::endl;
		std::cout << "@r0 linestyle 1" << std::endl;
		std::cout << "@r0 linewidth 1.0" << std::endl;
		std::cout << "@r0 color 1" << std::endl;
		std::cout << "@r0 line 0, 0, 0, 0" << std::endl;
		std::cout << "@r1 off" << std::endl;
		std::cout << "@link r1 to g0" << std::endl;
		std::cout << "@r1 type above" << std::endl;
		std::cout << "@r1 linestyle 1" << std::endl;
		std::cout << "@r1 linewidth 1.0" << std::endl;
		std::cout << "@r1 color 1" << std::endl;
		std::cout << "@r1 line 0, 0, 0, 0" << std::endl;
		std::cout << "@r2 off" << std::endl;
		std::cout << "@link r2 to g0" << std::endl;
		std::cout << "@r2 type above" << std::endl;
		std::cout << "@r2 linestyle 1" << std::endl;
		std::cout << "@r2 linewidth 1.0" << std::endl;
		std::cout << "@r2 color 1" << std::endl;
		std::cout << "@r2 line 0, 0, 0, 0" << std::endl;
		std::cout << "@r3 off" << std::endl;
		std::cout << "@link r3 to g0" << std::endl;
		std::cout << "@r3 type above" << std::endl;
		std::cout << "@r3 linestyle 1" << std::endl;
		std::cout << "@r3 linewidth 1.0" << std::endl;
		std::cout << "@r3 color 1" << std::endl;
		std::cout << "@r3 line 0, 0, 0, 0" << std::endl;
		std::cout << "@r4 off" << std::endl;
		std::cout << "@link r4 to g0" << std::endl;
		std::cout << "@r4 type above" << std::endl;
		std::cout << "@r4 linestyle 1" << std::endl;
		std::cout << "@r4 linewidth 1.0" << std::endl;
		std::cout << "@r4 color 1" << std::endl;
		std::cout << "@r4 line 0, 0, 0, 0" << std::endl;
		std::cout << "@g0 on" << std::endl;
		std::cout << "@g0 hidden false" << std::endl;
		std::cout << "@g0 type XY" << std::endl;
		std::cout << "@g0 stacked false" << std::endl;
		std::cout << "@g0 bar hgap 0.000000" << std::endl;
		std::cout << "@g0 fixedpoint off" << std::endl;
		std::cout << "@g0 fixedpoint type 0" << std::endl;
		std::cout << "@g0 fixedpoint xy 0.000000, 0.000000" << std::endl;
		std::cout << "@g0 fixedpoint format general general" << std::endl;
		std::cout << "@g0 fixedpoint prec 6, 6" << std::endl;
		std::cout << "@with g0" << std::endl;
		std::cout << "@    world -1, 1e-05, 1, 1" << std::endl;
		std::cout << "@    stack world 0, 0, 0, 0" << std::endl;
		std::cout << "@    znorm 1" << std::endl;
		std::cout << "@    view 0.150000, 0.644118, 1.145134, 0.850000" << std::endl;
		std::cout << "@    title \"\"" << std::endl;
		std::cout << "@    title font 0" << std::endl;
		std::cout << "@    title size 1.500000" << std::endl;
		std::cout << "@    title color 1" << std::endl;
		std::cout << "@    subtitle \"\"" << std::endl;
		std::cout << "@    subtitle font 0" << std::endl;
		std::cout << "@    subtitle size 1.000000" << std::endl;
		std::cout << "@    subtitle color 1" << std::endl;
		std::cout << "@    xaxes scale Normal" << std::endl;
		std::cout << "@    yaxes scale Logarithmic" << std::endl;
		std::cout << "@    xaxes invert off" << std::endl;
		std::cout << "@    yaxes invert off" << std::endl;
		std::cout << "@    xaxis  on" << std::endl;
		std::cout << "@    xaxis  type zero false" << std::endl;
		std::cout << "@    xaxis  offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    xaxis  bar on" << std::endl;
		std::cout << "@    xaxis  bar color 1" << std::endl;
		std::cout << "@    xaxis  bar linestyle 1" << std::endl;
		std::cout << "@    xaxis  bar linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  label \"\"" << std::endl;
		std::cout << "@    xaxis  label layout para" << std::endl;
		std::cout << "@    xaxis  label place auto" << std::endl;
		std::cout << "@    xaxis  label char size 1.000000" << std::endl;
		std::cout << "@    xaxis  label font 0" << std::endl;
		std::cout << "@    xaxis  label color 1" << std::endl;
		std::cout << "@    xaxis  label place normal" << std::endl;
		std::cout << "@    xaxis  tick on" << std::endl;
		std::cout << "@    xaxis  tick major 0.5" << std::endl;
		std::cout << "@    xaxis  tick minor ticks 1" << std::endl;
		std::cout << "@    xaxis  tick default 6" << std::endl;
		std::cout << "@    xaxis  tick place rounded true" << std::endl;
		std::cout << "@    xaxis  tick in" << std::endl;
		std::cout << "@    xaxis  tick major size 1.000000" << std::endl;
		std::cout << "@    xaxis  tick major color 1" << std::endl;
		std::cout << "@    xaxis  tick major linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  tick major linestyle 1" << std::endl;
		std::cout << "@    xaxis  tick major grid off" << std::endl;
		std::cout << "@    xaxis  tick minor color 1" << std::endl;
		std::cout << "@    xaxis  tick minor linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  tick minor linestyle 1" << std::endl;
		std::cout << "@    xaxis  tick minor grid off" << std::endl;
		std::cout << "@    xaxis  tick minor size 0.500000" << std::endl;
		std::cout << "@    xaxis  ticklabel on" << std::endl;
		std::cout << "@    xaxis  ticklabel format general" << std::endl;
		std::cout << "@    xaxis  ticklabel prec 5" << std::endl;
		std::cout << "@    xaxis  ticklabel formula \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel append \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel prepend \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel angle 0" << std::endl;
		std::cout << "@    xaxis  ticklabel skip 0" << std::endl;
		std::cout << "@    xaxis  ticklabel stagger 0" << std::endl;
		std::cout << "@    xaxis  ticklabel place normal" << std::endl;
		std::cout << "@    xaxis  ticklabel offset auto" << std::endl;
		std::cout << "@    xaxis  ticklabel offset 0.000000 , 0.010000" << std::endl;
		std::cout << "@    xaxis  ticklabel start type auto" << std::endl;
		std::cout << "@    xaxis  ticklabel start 0.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel stop type auto" << std::endl;
		std::cout << "@    xaxis  ticklabel stop 0.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel char size 1.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel font 0" << std::endl;
		std::cout << "@    xaxis  ticklabel color 1" << std::endl;
		std::cout << "@    xaxis  tick place both" << std::endl;
		std::cout << "@    xaxis  tick spec type none" << std::endl;
		std::cout << "@    yaxis  on" << std::endl;
		std::cout << "@    yaxis  type zero false" << std::endl;
		std::cout << "@    yaxis  offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    yaxis  bar on" << std::endl;
		std::cout << "@    yaxis  bar color 1" << std::endl;
		std::cout << "@    yaxis  bar linestyle 1" << std::endl;
		std::cout << "@    yaxis  bar linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  label \"T\"" << std::endl;
		std::cout << "@    yaxis  label layout para" << std::endl;
		std::cout << "@    yaxis  label place auto" << std::endl;
		std::cout << "@    yaxis  label char size 1.000000" << std::endl;
		std::cout << "@    yaxis  label font 0" << std::endl;
		std::cout << "@    yaxis  label color 1" << std::endl;
		std::cout << "@    yaxis  label place normal" << std::endl;
		std::cout << "@    yaxis  tick on" << std::endl;
		std::cout << "@    yaxis  tick major 10" << std::endl;
		std::cout << "@    yaxis  tick minor ticks 9" << std::endl;
		std::cout << "@    yaxis  tick default 6" << std::endl;
		std::cout << "@    yaxis  tick place rounded true" << std::endl;
		std::cout << "@    yaxis  tick in" << std::endl;
		std::cout << "@    yaxis  tick major size 1.000000" << std::endl;
		std::cout << "@    yaxis  tick major color 1" << std::endl;
		std::cout << "@    yaxis  tick major linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  tick major linestyle 1" << std::endl;
		std::cout << "@    yaxis  tick major grid off" << std::endl;
		std::cout << "@    yaxis  tick minor color 1" << std::endl;
		std::cout << "@    yaxis  tick minor linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  tick minor linestyle 1" << std::endl;
		std::cout << "@    yaxis  tick minor grid off" << std::endl;
		std::cout << "@    yaxis  tick minor size 0.500000" << std::endl;
		std::cout << "@    yaxis  ticklabel on" << std::endl;
		std::cout << "@    yaxis  ticklabel format power" << std::endl;
		std::cout << "@    yaxis  ticklabel prec 0" << std::endl;
		std::cout << "@    yaxis  ticklabel formula \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel append \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel prepend \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel angle 0" << std::endl;
		std::cout << "@    yaxis  ticklabel skip 0" << std::endl;
		std::cout << "@    yaxis  ticklabel stagger 0" << std::endl;
		std::cout << "@    yaxis  ticklabel place normal" << std::endl;
		std::cout << "@    yaxis  ticklabel offset auto" << std::endl;
		std::cout << "@    yaxis  ticklabel offset 0.000000 , 0.010000" << std::endl;
		std::cout << "@    yaxis  ticklabel start type auto" << std::endl;
		std::cout << "@    yaxis  ticklabel start 0.000000" << std::endl;
		std::cout << "@    yaxis  ticklabel stop type auto" << std::endl;
		std::cout << "@    yaxis  ticklabel stop 0.000000" << std::endl;
		std::cout << "@    yaxis  ticklabel char size 1.000000" << std::endl;
		std::cout << "@    yaxis  ticklabel font 0" << std::endl;
		std::cout << "@    yaxis  ticklabel color 1" << std::endl;
		std::cout << "@    yaxis  tick place both" << std::endl;
		std::cout << "@    yaxis  tick spec type none" << std::endl;
		std::cout << "@    altxaxis  off" << std::endl;
		std::cout << "@    altyaxis  off" << std::endl;
		std::cout << "@    legend on" << std::endl;
		std::cout << "@    legend loctype view" << std::endl;
		std::cout << "@    legend 0.98, 0.83" << std::endl;
		std::cout << "@    legend box color 1" << std::endl;
		std::cout << "@    legend box pattern 1" << std::endl;
		std::cout << "@    legend box linewidth 1.0" << std::endl;
		std::cout << "@    legend box linestyle 1" << std::endl;
		std::cout << "@    legend box fill color 0" << std::endl;
		std::cout << "@    legend box fill pattern 1" << std::endl;
		std::cout << "@    legend font 0" << std::endl;
		std::cout << "@    legend char size 1.000000" << std::endl;
		std::cout << "@    legend color 1" << std::endl;
		std::cout << "@    legend length 4" << std::endl;
		std::cout << "@    legend vgap 1" << std::endl;
		std::cout << "@    legend hgap 1" << std::endl;
		std::cout << "@    legend invert false" << std::endl;
		std::cout << "@    frame type 0" << std::endl;
		std::cout << "@    frame linestyle 1" << std::endl;
		std::cout << "@    frame linewidth 1.0" << std::endl;
		std::cout << "@    frame color 1" << std::endl;
		std::cout << "@    frame pattern 1" << std::endl;
		std::cout << "@    frame background color 0" << std::endl;
		std::cout << "@    frame background pattern 0" << std::endl;
		std::cout << "@    s0 hidden false" << std::endl;
		std::cout << "@    s0 type xy" << std::endl;
		std::cout << "@    s0 symbol 0" << std::endl;
		std::cout << "@    s0 symbol size 1.000000" << std::endl;
		std::cout << "@    s0 symbol color 1" << std::endl;
		std::cout << "@    s0 symbol pattern 1" << std::endl;
		std::cout << "@    s0 symbol fill color 1" << std::endl;
		std::cout << "@    s0 symbol fill pattern 0" << std::endl;
		std::cout << "@    s0 symbol linewidth 1.0" << std::endl;
		std::cout << "@    s0 symbol linestyle 1" << std::endl;
		std::cout << "@    s0 symbol char 65" << std::endl;
		std::cout << "@    s0 symbol char font 0" << std::endl;
		std::cout << "@    s0 symbol skip 0" << std::endl;
		std::cout << "@    s0 line type 1" << std::endl;
		std::cout << "@    s0 line linestyle 1" << std::endl;
		std::cout << "@    s0 line linewidth 2.0" << std::endl;
		std::cout << "@    s0 line color 1" << std::endl;
		std::cout << "@    s0 line pattern 1" << std::endl;
		std::cout << "@    s0 baseline type 0" << std::endl;
		std::cout << "@    s0 baseline off" << std::endl;
		std::cout << "@    s0 dropline off" << std::endl;
		std::cout << "@    s0 fill type 0" << std::endl;
		std::cout << "@    s0 fill rule 0" << std::endl;
		std::cout << "@    s0 fill color 1" << std::endl;
		std::cout << "@    s0 fill pattern 1" << std::endl;
		std::cout << "@    s0 avalue off" << std::endl;
		std::cout << "@    s0 avalue type 2" << std::endl;
		std::cout << "@    s0 avalue char size 1.000000" << std::endl;
		std::cout << "@    s0 avalue font 0" << std::endl;
		std::cout << "@    s0 avalue color 1" << std::endl;
		std::cout << "@    s0 avalue rot 0" << std::endl;
		std::cout << "@    s0 avalue format general" << std::endl;
		std::cout << "@    s0 avalue prec 3" << std::endl;
		std::cout << "@    s0 avalue prepend \"\"" << std::endl;
		std::cout << "@    s0 avalue append \"\"" << std::endl;
		std::cout << "@    s0 avalue offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    s0 errorbar on" << std::endl;
		std::cout << "@    s0 errorbar place both" << std::endl;
		std::cout << "@    s0 errorbar color 1" << std::endl;
		std::cout << "@    s0 errorbar pattern 1" << std::endl;
		std::cout << "@    s0 errorbar size 1.000000" << std::endl;
		std::cout << "@    s0 errorbar linewidth 1.0" << std::endl;
		std::cout << "@    s0 errorbar linestyle 1" << std::endl;
		std::cout << "@    s0 errorbar riser linewidth 1.0" << std::endl;
		std::cout << "@    s0 errorbar riser linestyle 1" << std::endl;
		std::cout << "@    s0 errorbar riser clip off" << std::endl;
		std::cout << "@    s0 errorbar riser clip length 0.100000" << std::endl;
		std::cout << "@    s0 comment \"Cols 1:2\"" << std::endl;
		std::cout << "@    s0 legend  \"A->B\"" << std::endl;
		std::cout << "@g1 on" << std::endl;
		std::cout << "@g1 hidden false" << std::endl;
		std::cout << "@g1 type XY" << std::endl;
		std::cout << "@g1 stacked false" << std::endl;
		std::cout << "@g1 bar hgap 0.000000" << std::endl;
		std::cout << "@g1 fixedpoint off" << std::endl;
		std::cout << "@g1 fixedpoint type 0" << std::endl;
		std::cout << "@g1 fixedpoint xy 0.000000, 0.000000" << std::endl;
		std::cout << "@g1 fixedpoint format general general" << std::endl;
		std::cout << "@g1 fixedpoint prec 6, 6" << std::endl;
		std::cout << "@with g1" << std::endl;
		std::cout << "@    world -1, 0, 1, 1" << std::endl;
		std::cout << "@    stack world 0, 0, 0, 0" << std::endl;
		std::cout << "@    znorm 1" << std::endl;
		std::cout << "@    view 0.150000, 0.397059, 1.145134, 0.602941" << std::endl;
		std::cout << "@    title \"\"" << std::endl;
		std::cout << "@    title font 0" << std::endl;
		std::cout << "@    title size 1.500000" << std::endl;
		std::cout << "@    title color 1" << std::endl;
		std::cout << "@    subtitle \"\"" << std::endl;
		std::cout << "@    subtitle font 0" << std::endl;
		std::cout << "@    subtitle size 1.000000" << std::endl;
		std::cout << "@    subtitle color 1" << std::endl;
		std::cout << "@    xaxes scale Normal" << std::endl;
		std::cout << "@    yaxes scale Normal" << std::endl;
		std::cout << "@    xaxes invert off" << std::endl;
		std::cout << "@    yaxes invert off" << std::endl;
		std::cout << "@    xaxis  on" << std::endl;
		std::cout << "@    xaxis  type zero false" << std::endl;
		std::cout << "@    xaxis  offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    xaxis  bar on" << std::endl;
		std::cout << "@    xaxis  bar color 1" << std::endl;
		std::cout << "@    xaxis  bar linestyle 1" << std::endl;
		std::cout << "@    xaxis  bar linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  label \"\"" << std::endl;
		std::cout << "@    xaxis  label layout para" << std::endl;
		std::cout << "@    xaxis  label place auto" << std::endl;
		std::cout << "@    xaxis  label char size 1.000000" << std::endl;
		std::cout << "@    xaxis  label font 0" << std::endl;
		std::cout << "@    xaxis  label color 1" << std::endl;
		std::cout << "@    xaxis  label place normal" << std::endl;
		std::cout << "@    xaxis  tick on" << std::endl;
		std::cout << "@    xaxis  tick major 0.5" << std::endl;
		std::cout << "@    xaxis  tick minor ticks 1" << std::endl;
		std::cout << "@    xaxis  tick default 6" << std::endl;
		std::cout << "@    xaxis  tick place rounded true" << std::endl;
		std::cout << "@    xaxis  tick in" << std::endl;
		std::cout << "@    xaxis  tick major size 1.000000" << std::endl;
		std::cout << "@    xaxis  tick major color 1" << std::endl;
		std::cout << "@    xaxis  tick major linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  tick major linestyle 1" << std::endl;
		std::cout << "@    xaxis  tick major grid off" << std::endl;
		std::cout << "@    xaxis  tick minor color 1" << std::endl;
		std::cout << "@    xaxis  tick minor linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  tick minor linestyle 1" << std::endl;
		std::cout << "@    xaxis  tick minor grid off" << std::endl;
		std::cout << "@    xaxis  tick minor size 0.500000" << std::endl;
		std::cout << "@    xaxis  ticklabel on" << std::endl;
		std::cout << "@    xaxis  ticklabel format general" << std::endl;
		std::cout << "@    xaxis  ticklabel prec 5" << std::endl;
		std::cout << "@    xaxis  ticklabel formula \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel append \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel prepend \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel angle 0" << std::endl;
		std::cout << "@    xaxis  ticklabel skip 0" << std::endl;
		std::cout << "@    xaxis  ticklabel stagger 0" << std::endl;
		std::cout << "@    xaxis  ticklabel place normal" << std::endl;
		std::cout << "@    xaxis  ticklabel offset auto" << std::endl;
		std::cout << "@    xaxis  ticklabel offset 0.000000 , 0.010000" << std::endl;
		std::cout << "@    xaxis  ticklabel start type auto" << std::endl;
		std::cout << "@    xaxis  ticklabel start 0.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel stop type auto" << std::endl;
		std::cout << "@    xaxis  ticklabel stop 0.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel char size 1.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel font 0" << std::endl;
		std::cout << "@    xaxis  ticklabel color 1" << std::endl;
		std::cout << "@    xaxis  tick place both" << std::endl;
		std::cout << "@    xaxis  tick spec type none" << std::endl;
		std::cout << "@    yaxis  on" << std::endl;
		std::cout << "@    yaxis  type zero false" << std::endl;
		std::cout << "@    yaxis  offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    yaxis  bar on" << std::endl;
		std::cout << "@    yaxis  bar color 1" << std::endl;
		std::cout << "@    yaxis  bar linestyle 1" << std::endl;
		std::cout << "@    yaxis  bar linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  label \"open ch.\"" << std::endl;
		std::cout << "@    yaxis  label layout para" << std::endl;
		std::cout << "@    yaxis  label place auto" << std::endl;
		std::cout << "@    yaxis  label char size 1.000000" << std::endl;
		std::cout << "@    yaxis  label font 0" << std::endl;
		std::cout << "@    yaxis  label color 1" << std::endl;
		std::cout << "@    yaxis  label place normal" << std::endl;
		std::cout << "@    yaxis  tick on" << std::endl;
		std::cout << "@    yaxis  tick major 0.2" << std::endl;
		std::cout << "@    yaxis  tick minor ticks 1" << std::endl;
		std::cout << "@    yaxis  tick default 6" << std::endl;
		std::cout << "@    yaxis  tick place rounded true" << std::endl;
		std::cout << "@    yaxis  tick in" << std::endl;
		std::cout << "@    yaxis  tick major size 1.000000" << std::endl;
		std::cout << "@    yaxis  tick major color 1" << std::endl;
		std::cout << "@    yaxis  tick major linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  tick major linestyle 1" << std::endl;
		std::cout << "@    yaxis  tick major grid off" << std::endl;
		std::cout << "@    yaxis  tick minor color 1" << std::endl;
		std::cout << "@    yaxis  tick minor linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  tick minor linestyle 1" << std::endl;
		std::cout << "@    yaxis  tick minor grid off" << std::endl;
		std::cout << "@    yaxis  tick minor size 0.500000" << std::endl;
		std::cout << "@    yaxis  ticklabel on" << std::endl;
		std::cout << "@    yaxis  ticklabel format general" << std::endl;
		std::cout << "@    yaxis  ticklabel prec 5" << std::endl;
		std::cout << "@    yaxis  ticklabel formula \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel append \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel prepend \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel angle 0" << std::endl;
		std::cout << "@    yaxis  ticklabel skip 0" << std::endl;
		std::cout << "@    yaxis  ticklabel stagger 0" << std::endl;
		std::cout << "@    yaxis  ticklabel place normal" << std::endl;
		std::cout << "@    yaxis  ticklabel offset auto" << std::endl;
		std::cout << "@    yaxis  ticklabel offset 0.000000 , 0.010000" << std::endl;
		std::cout << "@    yaxis  ticklabel start type auto" << std::endl;
		std::cout << "@    yaxis  ticklabel start 0.000000" << std::endl;
		std::cout << "@    yaxis  ticklabel stop type auto" << std::endl;
		std::cout << "@    yaxis  ticklabel stop 0.000000" << std::endl;
		std::cout << "@    yaxis  ticklabel char size 1.000000" << std::endl;
		std::cout << "@    yaxis  ticklabel font 0" << std::endl;
		std::cout << "@    yaxis  ticklabel color 1" << std::endl;
		std::cout << "@    yaxis  tick place both" << std::endl;
		std::cout << "@    yaxis  tick spec type none" << std::endl;
		std::cout << "@    altxaxis  off" << std::endl;
		std::cout << "@    altyaxis  off" << std::endl;
		std::cout << "@    legend on" << std::endl;
		std::cout << "@    legend loctype view" << std::endl;
		std::cout << "@    legend 1.02, 0.58" << std::endl;
		std::cout << "@    legend box color 1" << std::endl;
		std::cout << "@    legend box pattern 1" << std::endl;
		std::cout << "@    legend box linewidth 1.0" << std::endl;
		std::cout << "@    legend box linestyle 1" << std::endl;
		std::cout << "@    legend box fill color 0" << std::endl;
		std::cout << "@    legend box fill pattern 1" << std::endl;
		std::cout << "@    legend font 0" << std::endl;
		std::cout << "@    legend char size 1.000000" << std::endl;
		std::cout << "@    legend color 1" << std::endl;
		std::cout << "@    legend length 4" << std::endl;
		std::cout << "@    legend vgap 1" << std::endl;
		std::cout << "@    legend hgap 1" << std::endl;
		std::cout << "@    legend invert false" << std::endl;
		std::cout << "@    frame type 0" << std::endl;
		std::cout << "@    frame linestyle 1" << std::endl;
		std::cout << "@    frame linewidth 1.0" << std::endl;
		std::cout << "@    frame color 1" << std::endl;
		std::cout << "@    frame pattern 1" << std::endl;
		std::cout << "@    frame background color 0" << std::endl;
		std::cout << "@    frame background pattern 0" << std::endl;
		std::cout << "@    s0 hidden false" << std::endl;
		std::cout << "@    s0 type xy" << std::endl;
		std::cout << "@    s0 symbol 8" << std::endl;
		std::cout << "@    s0 symbol size 0.240000" << std::endl;
		std::cout << "@    s0 symbol color 4" << std::endl;
		std::cout << "@    s0 symbol pattern 1" << std::endl;
		std::cout << "@    s0 symbol fill color 4" << std::endl;
		std::cout << "@    s0 symbol fill pattern 0" << std::endl;
		std::cout << "@    s0 symbol linewidth 1.0" << std::endl;
		std::cout << "@    s0 symbol linestyle 1" << std::endl;
		std::cout << "@    s0 symbol char 65" << std::endl;
		std::cout << "@    s0 symbol char font 0" << std::endl;
		std::cout << "@    s0 symbol skip 0" << std::endl;
		std::cout << "@    s0 line type 1" << std::endl;
		std::cout << "@    s0 line linestyle 1" << std::endl;
		std::cout << "@    s0 line linewidth 1.0" << std::endl;
		std::cout << "@    s0 line color 4" << std::endl;
		std::cout << "@    s0 line pattern 1" << std::endl;
		std::cout << "@    s0 baseline type 0" << std::endl;
		std::cout << "@    s0 baseline off" << std::endl;
		std::cout << "@    s0 dropline off" << std::endl;
		std::cout << "@    s0 fill type 0" << std::endl;
		std::cout << "@    s0 fill rule 0" << std::endl;
		std::cout << "@    s0 fill color 1" << std::endl;
		std::cout << "@    s0 fill pattern 1" << std::endl;
		std::cout << "@    s0 avalue off" << std::endl;
		std::cout << "@    s0 avalue type 2" << std::endl;
		std::cout << "@    s0 avalue char size 1.000000" << std::endl;
		std::cout << "@    s0 avalue font 0" << std::endl;
		std::cout << "@    s0 avalue color 1" << std::endl;
		std::cout << "@    s0 avalue rot 0" << std::endl;
		std::cout << "@    s0 avalue format general" << std::endl;
		std::cout << "@    s0 avalue prec 3" << std::endl;
		std::cout << "@    s0 avalue prepend \"\"" << std::endl;
		std::cout << "@    s0 avalue append \"\"" << std::endl;
		std::cout << "@    s0 avalue offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    s0 errorbar on" << std::endl;
		std::cout << "@    s0 errorbar place both" << std::endl;
		std::cout << "@    s0 errorbar color 4" << std::endl;
		std::cout << "@    s0 errorbar pattern 1" << std::endl;
		std::cout << "@    s0 errorbar size 1.000000" << std::endl;
		std::cout << "@    s0 errorbar linewidth 1.0" << std::endl;
		std::cout << "@    s0 errorbar linestyle 1" << std::endl;
		std::cout << "@    s0 errorbar riser linewidth 1.0" << std::endl;
		std::cout << "@    s0 errorbar riser linestyle 1" << std::endl;
		std::cout << "@    s0 errorbar riser clip off" << std::endl;
		std::cout << "@    s0 errorbar riser clip length 0.100000" << std::endl;
		std::cout << "@    s0 comment \"Cols 1:6\"" << std::endl;
		std::cout << "@    s0 legend  \"A\"" << std::endl;
		std::cout << "@    s1 hidden false" << std::endl;
		std::cout << "@    s1 type xy" << std::endl;
		std::cout << "@    s1 symbol 9" << std::endl;
		std::cout << "@    s1 symbol size 0.240000" << std::endl;
		std::cout << "@    s1 symbol color 2" << std::endl;
		std::cout << "@    s1 symbol pattern 1" << std::endl;
		std::cout << "@    s1 symbol fill color 2" << std::endl;
		std::cout << "@    s1 symbol fill pattern 0" << std::endl;
		std::cout << "@    s1 symbol linewidth 1.0" << std::endl;
		std::cout << "@    s1 symbol linestyle 1" << std::endl;
		std::cout << "@    s1 symbol char 65" << std::endl;
		std::cout << "@    s1 symbol char font 0" << std::endl;
		std::cout << "@    s1 symbol skip 0" << std::endl;
		std::cout << "@    s1 line type 1" << std::endl;
		std::cout << "@    s1 line linestyle 3" << std::endl;
		std::cout << "@    s1 line linewidth 1.0" << std::endl;
		std::cout << "@    s1 line color 2" << std::endl;
		std::cout << "@    s1 line pattern 1" << std::endl;
		std::cout << "@    s1 baseline type 0" << std::endl;
		std::cout << "@    s1 baseline off" << std::endl;
		std::cout << "@    s1 dropline off" << std::endl;
		std::cout << "@    s1 fill type 0" << std::endl;
		std::cout << "@    s1 fill rule 0" << std::endl;
		std::cout << "@    s1 fill color 1" << std::endl;
		std::cout << "@    s1 fill pattern 1" << std::endl;
		std::cout << "@    s1 avalue off" << std::endl;
		std::cout << "@    s1 avalue type 2" << std::endl;
		std::cout << "@    s1 avalue char size 1.000000" << std::endl;
		std::cout << "@    s1 avalue font 0" << std::endl;
		std::cout << "@    s1 avalue color 1" << std::endl;
		std::cout << "@    s1 avalue rot 0" << std::endl;
		std::cout << "@    s1 avalue format general" << std::endl;
		std::cout << "@    s1 avalue prec 3" << std::endl;
		std::cout << "@    s1 avalue prepend \"\"" << std::endl;
		std::cout << "@    s1 avalue append \"\"" << std::endl;
		std::cout << "@    s1 avalue offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    s1 errorbar on" << std::endl;
		std::cout << "@    s1 errorbar place both" << std::endl;
		std::cout << "@    s1 errorbar color 2" << std::endl;
		std::cout << "@    s1 errorbar pattern 1" << std::endl;
		std::cout << "@    s1 errorbar size 1.000000" << std::endl;
		std::cout << "@    s1 errorbar linewidth 1.0" << std::endl;
		std::cout << "@    s1 errorbar linestyle 1" << std::endl;
		std::cout << "@    s1 errorbar riser linewidth 1.0" << std::endl;
		std::cout << "@    s1 errorbar riser linestyle 1" << std::endl;
		std::cout << "@    s1 errorbar riser clip off" << std::endl;
		std::cout << "@    s1 errorbar riser clip length 0.100000" << std::endl;
		std::cout << "@    s1 comment \"Cols 1:7\"" << std::endl;
		std::cout << "@    s1 legend  \"B\"" << std::endl;
		std::cout << "@g2 on" << std::endl;
		std::cout << "@g2 hidden false" << std::endl;
		std::cout << "@g2 type XY" << std::endl;
		std::cout << "@g2 stacked false" << std::endl;
		std::cout << "@g2 bar hgap 0.000000" << std::endl;
		std::cout << "@g2 fixedpoint off" << std::endl;
		std::cout << "@g2 fixedpoint type 0" << std::endl;
		std::cout << "@g2 fixedpoint xy 0.000000, 0.000000" << std::endl;
		std::cout << "@g2 fixedpoint format general general" << std::endl;
		std::cout << "@g2 fixedpoint prec 6, 6" << std::endl;
		std::cout << "@with g2" << std::endl;
		std::cout << "@    world -1, 1e-10, 1, 1" << std::endl;
		std::cout << "@    stack world 0, 0, 0, 0" << std::endl;
		std::cout << "@    znorm 1" << std::endl;
		std::cout << "@    view 0.150000, 0.150000, 1.145134, 0.355882" << std::endl;
		std::cout << "@    title \"\"" << std::endl;
		std::cout << "@    title font 0" << std::endl;
		std::cout << "@    title size 1.500000" << std::endl;
		std::cout << "@    title color 1" << std::endl;
		std::cout << "@    subtitle \"\"" << std::endl;
		std::cout << "@    subtitle font 0" << std::endl;
		std::cout << "@    subtitle size 1.000000" << std::endl;
		std::cout << "@    subtitle color 1" << std::endl;
		std::cout << "@    xaxes scale Normal" << std::endl;
		std::cout << "@    yaxes scale Logarithmic" << std::endl;
		std::cout << "@    xaxes invert off" << std::endl;
		std::cout << "@    yaxes invert off" << std::endl;
		std::cout << "@    xaxis  on" << std::endl;
		std::cout << "@    xaxis  type zero false" << std::endl;
		std::cout << "@    xaxis  offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    xaxis  bar on" << std::endl;
		std::cout << "@    xaxis  bar color 1" << std::endl;
		std::cout << "@    xaxis  bar linestyle 1" << std::endl;
		std::cout << "@    xaxis  bar linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  label \"E-E\\sF \\N [eV]\"" << std::endl;
		std::cout << "@    xaxis  label layout para" << std::endl;
		std::cout << "@    xaxis  label place auto" << std::endl;
		std::cout << "@    xaxis  label char size 1.000000" << std::endl;
		std::cout << "@    xaxis  label font 0" << std::endl;
		std::cout << "@    xaxis  label color 1" << std::endl;
		std::cout << "@    xaxis  label place normal" << std::endl;
		std::cout << "@    xaxis  tick on" << std::endl;
		std::cout << "@    xaxis  tick major 0.5" << std::endl;
		std::cout << "@    xaxis  tick minor ticks 1" << std::endl;
		std::cout << "@    xaxis  tick default 6" << std::endl;
		std::cout << "@    xaxis  tick place rounded true" << std::endl;
		std::cout << "@    xaxis  tick in" << std::endl;
		std::cout << "@    xaxis  tick major size 1.000000" << std::endl;
		std::cout << "@    xaxis  tick major color 1" << std::endl;
		std::cout << "@    xaxis  tick major linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  tick major linestyle 1" << std::endl;
		std::cout << "@    xaxis  tick major grid off" << std::endl;
		std::cout << "@    xaxis  tick minor color 1" << std::endl;
		std::cout << "@    xaxis  tick minor linewidth 1.0" << std::endl;
		std::cout << "@    xaxis  tick minor linestyle 1" << std::endl;
		std::cout << "@    xaxis  tick minor grid off" << std::endl;
		std::cout << "@    xaxis  tick minor size 0.500000" << std::endl;
		std::cout << "@    xaxis  ticklabel on" << std::endl;
		std::cout << "@    xaxis  ticklabel format general" << std::endl;
		std::cout << "@    xaxis  ticklabel prec 5" << std::endl;
		std::cout << "@    xaxis  ticklabel formula \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel append \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel prepend \"\"" << std::endl;
		std::cout << "@    xaxis  ticklabel angle 0" << std::endl;
		std::cout << "@    xaxis  ticklabel skip 0" << std::endl;
		std::cout << "@    xaxis  ticklabel stagger 0" << std::endl;
		std::cout << "@    xaxis  ticklabel place normal" << std::endl;
		std::cout << "@    xaxis  ticklabel offset auto" << std::endl;
		std::cout << "@    xaxis  ticklabel offset 0.000000 , 0.010000" << std::endl;
		std::cout << "@    xaxis  ticklabel start type auto" << std::endl;
		std::cout << "@    xaxis  ticklabel start 0.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel stop type auto" << std::endl;
		std::cout << "@    xaxis  ticklabel stop 0.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel char size 1.000000" << std::endl;
		std::cout << "@    xaxis  ticklabel font 0" << std::endl;
		std::cout << "@    xaxis  ticklabel color 1" << std::endl;
		std::cout << "@    xaxis  tick place both" << std::endl;
		std::cout << "@    xaxis  tick spec type none" << std::endl;
		std::cout << "@    yaxis  on" << std::endl;
		std::cout << "@    yaxis  type zero false" << std::endl;
		std::cout << "@    yaxis  offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    yaxis  bar on" << std::endl;
		std::cout << "@    yaxis  bar color 1" << std::endl;
		std::cout << "@    yaxis  bar linestyle 1" << std::endl;
		std::cout << "@    yaxis  bar linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  label \"Error est.\"" << std::endl;
		std::cout << "@    yaxis  label layout para" << std::endl;
		std::cout << "@    yaxis  label place auto" << std::endl;
		std::cout << "@    yaxis  label char size 1.070000" << std::endl;
		std::cout << "@    yaxis  label font 0" << std::endl;
		std::cout << "@    yaxis  label color 1" << std::endl;
		std::cout << "@    yaxis  label place normal" << std::endl;
		std::cout << "@    yaxis  tick on" << std::endl;
		std::cout << "@    yaxis  tick major 100" << std::endl;
		std::cout << "@    yaxis  tick minor ticks 0" << std::endl;
		std::cout << "@    yaxis  tick default 6" << std::endl;
		std::cout << "@    yaxis  tick place rounded true" << std::endl;
		std::cout << "@    yaxis  tick in" << std::endl;
		std::cout << "@    yaxis  tick major size 1.000000" << std::endl;
		std::cout << "@    yaxis  tick major color 1" << std::endl;
		std::cout << "@    yaxis  tick major linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  tick major linestyle 1" << std::endl;
		std::cout << "@    yaxis  tick major grid off" << std::endl;
		std::cout << "@    yaxis  tick minor color 1" << std::endl;
		std::cout << "@    yaxis  tick minor linewidth 1.0" << std::endl;
		std::cout << "@    yaxis  tick minor linestyle 1" << std::endl;
		std::cout << "@    yaxis  tick minor grid off" << std::endl;
		std::cout << "@    yaxis  tick minor size 0.500000" << std::endl;
		std::cout << "@    yaxis  ticklabel on" << std::endl;
		std::cout << "@    yaxis  ticklabel format power" << std::endl;
		std::cout << "@    yaxis  ticklabel prec 0" << std::endl;
		std::cout << "@    yaxis  ticklabel formula \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel append \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel prepend \"\"" << std::endl;
		std::cout << "@    yaxis  ticklabel angle 0" << std::endl;
		std::cout << "@    yaxis  ticklabel skip 0" << std::endl;
		std::cout << "@    yaxis  ticklabel stagger 0" << std::endl;
		std::cout << "@    yaxis  ticklabel place normal" << std::endl;
		std::cout << "@    yaxis  ticklabel offset auto" << std::endl;
		std::cout << "@    yaxis  ticklabel offset 0.000000 , 0.010000" << std::endl;
		std::cout << "@    yaxis  ticklabel start type auto" << std::endl;
		std::cout << "@    yaxis  ticklabel start 0.000000" << std::endl;
		std::cout << "@    yaxis  ticklabel stop type auto" << std::endl;
		std::cout << "@    yaxis  ticklabel stop 0.000000" << std::endl;
		std::cout << "@    yaxis  ticklabel char size 0.620000" << std::endl;
		std::cout << "@    yaxis  ticklabel font 0" << std::endl;
		std::cout << "@    yaxis  ticklabel color 1" << std::endl;
		std::cout << "@    yaxis  tick place both" << std::endl;
		std::cout << "@    yaxis  tick spec type none" << std::endl;
		std::cout << "@    altxaxis  off" << std::endl;
		std::cout << "@    altyaxis  off" << std::endl;
		std::cout << "@    legend on" << std::endl;
		std::cout << "@    legend loctype view" << std::endl;
		std::cout << "@    legend 0.5, 0.8" << std::endl;
		std::cout << "@    legend box color 1" << std::endl;
		std::cout << "@    legend box pattern 1" << std::endl;
		std::cout << "@    legend box linewidth 1.0" << std::endl;
		std::cout << "@    legend box linestyle 1" << std::endl;
		std::cout << "@    legend box fill color 0" << std::endl;
		std::cout << "@    legend box fill pattern 1" << std::endl;
		std::cout << "@    legend font 0" << std::endl;
		std::cout << "@    legend char size 1.000000" << std::endl;
		std::cout << "@    legend color 1" << std::endl;
		std::cout << "@    legend length 4" << std::endl;
		std::cout << "@    legend vgap 1" << std::endl;
		std::cout << "@    legend hgap 1" << std::endl;
		std::cout << "@    legend invert false" << std::endl;
		std::cout << "@    frame type 0" << std::endl;
		std::cout << "@    frame linestyle 1" << std::endl;
		std::cout << "@    frame linewidth 1.0" << std::endl;
		std::cout << "@    frame color 1" << std::endl;
		std::cout << "@    frame pattern 1" << std::endl;
		std::cout << "@    frame background color 0" << std::endl;
		std::cout << "@    frame background pattern 0" << std::endl;
		std::cout << "@    s0 hidden false" << std::endl;
		std::cout << "@    s0 type xy" << std::endl;
		std::cout << "@    s0 symbol 0" << std::endl;
		std::cout << "@    s0 symbol size 1.000000" << std::endl;
		std::cout << "@    s0 symbol color 1" << std::endl;
		std::cout << "@    s0 symbol pattern 1" << std::endl;
		std::cout << "@    s0 symbol fill color 1" << std::endl;
		std::cout << "@    s0 symbol fill pattern 0" << std::endl;
		std::cout << "@    s0 symbol linewidth 1.0" << std::endl;
		std::cout << "@    s0 symbol linestyle 1" << std::endl;
		std::cout << "@    s0 symbol char 65" << std::endl;
		std::cout << "@    s0 symbol char font 0" << std::endl;
		std::cout << "@    s0 symbol skip 0" << std::endl;
		std::cout << "@    s0 line type 1" << std::endl;
		std::cout << "@    s0 line linestyle 1" << std::endl;
		std::cout << "@    s0 line linewidth 2.0" << std::endl;
		std::cout << "@    s0 line color 1" << std::endl;
		std::cout << "@    s0 line pattern 1" << std::endl;
		std::cout << "@    s0 baseline type 0" << std::endl;
		std::cout << "@    s0 baseline off" << std::endl;
		std::cout << "@    s0 dropline off" << std::endl;
		std::cout << "@    s0 fill type 0" << std::endl;
		std::cout << "@    s0 fill rule 0" << std::endl;
		std::cout << "@    s0 fill color 1" << std::endl;
		std::cout << "@    s0 fill pattern 1" << std::endl;
		std::cout << "@    s0 avalue off" << std::endl;
		std::cout << "@    s0 avalue type 2" << std::endl;
		std::cout << "@    s0 avalue char size 1.000000" << std::endl;
		std::cout << "@    s0 avalue font 0" << std::endl;
		std::cout << "@    s0 avalue color 1" << std::endl;
		std::cout << "@    s0 avalue rot 0" << std::endl;
		std::cout << "@    s0 avalue format general" << std::endl;
		std::cout << "@    s0 avalue prec 3" << std::endl;
		std::cout << "@    s0 avalue prepend \"\"" << std::endl;
		std::cout << "@    s0 avalue append \"\"" << std::endl;
		std::cout << "@    s0 avalue offset 0.000000 , 0.000000" << std::endl;
		std::cout << "@    s0 errorbar on" << std::endl;
		std::cout << "@    s0 errorbar place both" << std::endl;
		std::cout << "@    s0 errorbar color 1" << std::endl;
		std::cout << "@    s0 errorbar pattern 1" << std::endl;
		std::cout << "@    s0 errorbar size 1.000000" << std::endl;
		std::cout << "@    s0 errorbar linewidth 1.0" << std::endl;
		std::cout << "@    s0 errorbar linestyle 1" << std::endl;
		std::cout << "@    s0 errorbar riser linewidth 1.0" << std::endl;
		std::cout << "@    s0 errorbar riser linestyle 1" << std::endl;
		std::cout << "@    s0 errorbar riser clip off" << std::endl;
		std::cout << "@    s0 errorbar riser clip length 0.100000" << std::endl;
		std::cout << "@    s0 comment \"Cols 1:8\"" << std::endl;
		std::cout << "@    s0 legend  \"\"" << std::endl;

		std::cout << "@target G0.S0" << std::endl;
		std::cout << "@type xy" << std::endl;
                for(int i=0;i<N;i++)
                {
                     std::cout << en[i] << "  " << tab[i] << std::endl;
                }
		std::cout << "&" << std::endl;
		std::cout << "@target G1.S0" << std::endl;
		std::cout << "@type xy" << std::endl;
                for(int i=0;i<N;i++)
                {
                     std::cout << en[i] << "  " << aoc[i] << std::endl;
                }
		std::cout << "&" << std::endl;
		std::cout << "@target G1.S1" << std::endl;
		std::cout << "@type xy" << std::endl;
                for(int i=0;i<N;i++)
                {
                     std::cout << en[i] << "  " << boc[i] << std::endl;
                }
		std::cout << "&" << std::endl;
		std::cout << "@target G2.S0" << std::endl;
		std::cout << "@type xy" << std::endl;
                for(int i=0;i<N;i++)
                {
                     std::cout << en[i] << "  " << err[i] << std::endl;
                }
		std::cout << "&" << std::endl;

            


        }            
            
        

        
} catch(const char* message)
{
    std::cerr << message << std::endl;
    std::cerr << "(exit)" << std::endl;
    return EXIT_FAILURE;
}
catch(const std::exception & e)
{
    std::cerr << e.what() << std::endl;
    std::cerr << "(exit)" << std::endl;
    return EXIT_FAILURE;
}
    return EXIT_SUCCESS;
            

}

